<template>
	<div id="app">
		<router-view></router-view>
		<web-socket v-if="userId" ref="websock" :userId="userId"></web-socket>
	</div>
</template>

<script>
import WebSocket from '@/components/WebSocket'
import {
	mapState
} from 'vuex'
import {
	getToken
} from '@/utils/auth.js'
export default {
	name: 'app',
	components: {
		WebSocket
	},
	data() {
		return {}
	},
	computed: {
		...mapState({
			userId: (state) => state.user.id
		})
	},
	mounted() {
		if (getToken() && !this.userId) {
			this.$store.dispatch('GET_USERINFO')
		}
		console.log('进入系统');
	}
}
</script>

<style>
div {

	box-sizing: border-box;
}

body {
	margin: 0;
}

#app {
	margin: 0;
	padding: 0;
}
</style>